package com.example.docmanagement.repository;

import com.example.docmanagement.entity.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 权限数据访问层
 */
@Repository
public interface PermissionRepository extends JpaRepository<Permission, Long>, JpaSpecificationExecutor<Permission> {

    /**
     * 根据权限标识查询
     */
    Optional<Permission> findByName(String name);

    /**
     * 查询指定模块下的全部权限
     */
    List<Permission> findByResourceOrderBySortOrderAsc(String resource);

    /**
     * 判断权限标识是否存在
     */
    boolean existsByName(String name);
}


